package com.example.exemplo01;

import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {
	
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.principal);
        
        chamaPrincipal();     
    }
    
    public void chamaCadastro(){
    	setContentView(R.layout.cadastro);
    	
      Button btprincipal = (Button) findViewById(R.id.btmenuprincipal);
        
        btprincipal.setOnClickListener(new View.OnClickListener() {
        	
			@Override
			public void onClick(View v) {
				chamaPrincipal();
			}
		});
    }
    
    public void chamaConsulta(){
    	setContentView(R.layout.consulta);
    	
      Button btvoltar = (Button) findViewById(R.id.btvoltar);
    	
        btvoltar.setOnClickListener(new View.OnClickListener() {        	
			@Override
			public void onClick(View v) {
				chamaPrincipal();
			}
		});
    }
    
    public void chamaPrincipal(){
    	setContentView(R.layout.principal);
    	
        Button btcadastro = (Button) findViewById(R.id.btcadastro);
        Button btconsulta = (Button) findViewById(R.id.btconsulta);
          
          btcadastro.setOnClickListener(new View.OnClickListener() {
  			
  			@Override
  			public void onClick(View v) {
  				chamaCadastro();				
  			}
  		});
          
          btconsulta.setOnClickListener(new View.OnClickListener() {
  	
  			@Override
  			public void onClick(View v) {
  				chamaConsulta();
  			}
  		});

    }
}
